//
//  ViewController.m
//  UIMenuControllerTest
//
//  Created by xiaoming on 16/10/26.
//  Copyright © 2016年 xiaoming. All rights reserved.
//

#import "ViewController.h"
#import "XMAccessableLabel.h"

@interface ViewController ()

@end

@implementation ViewController {
    UIMenuController *menuController;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    CGFloat y = 100;
    for (NSInteger i = 0; i < 2; i++) {
        XMAccessableLabel *lab = [[XMAccessableLabel alloc] initWithFrame:CGRectMake(0, y + y * (i + 1), 200, y)];
        lab.text = @"我们是中国高校联盟";
        lab.numberOfLines = 0;
        [self.view addSubview:lab];
        lab.userInteractionEnabled = YES;
        lab.center = CGPointMake([UIScreen mainScreen].bounds.size.width / 2.0, lab.center.y);
        
        UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(longAction:)];
        [lab addGestureRecognizer:pan];
    }
}

- (void)longAction:(UIPanGestureRecognizer *)ges {
    UILabel *lab = (UILabel *)ges.view;
    CGPoint transit = [ges translationInView:lab];
    CGPoint center = lab.center;
    transit = CGPointApplyAffineTransform(center, CGAffineTransformMakeTranslation(transit.x, transit.y));
    lab.center = transit;
    [ges setTranslation:CGPointZero inView:ges.view];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
